//
//  LogInVc.m
//  MJApp
//
//  Created by John on 15/5/12.
//  Copyright (c) 2015年 wangliang. All rights reserved.
//

#import "LogInVc.h"
#import "AppDelegate.h"
@interface LogInVc ()
@property (weak, nonatomic) IBOutlet UITextField *phoneText;
@property (weak, nonatomic) IBOutlet UITextField *pwdText;

@end

@implementation LogInVc

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)LogIn:(UIButton *)sender {
    NSMutableDictionary * param = [NSMutableDictionary dictionary];
    param[@"user_name"] = self.phoneText.text;
    param[@"password"] = self.pwdText.text;
    [WLHTTPRequest logInWithParam:param usingSucessBlock:^(BOOL isSucess, NSDictionary *resultDictionary) {
        NSLog(@"%@",resultDictionary);
        NSLog(@"%@",resultDictionary[@"data"][@"token"]);
        if ([resultDictionary[@"status"] intValue]==1) {
            [[NSUserDefaults standardUserDefaults] setObject:resultDictionary[@"data"] forKey:userInf];
            [[NSUserDefaults standardUserDefaults] synchronize];
            AppDelegate * appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
            [appdelegate choseRootVc];
        }
    } andFailureBlock:^(NSError *resultError) {
        
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
